} else if options.arg_crate == None {
try!(SourceId::for_path(&config.cwd()))
} else {
- try!(SourceId::for_central(config))
+ try!(SourceId::crates_io(config))
};
let krate = options.arg_crate.as_ref().map(|s| &s[..]);
let token = match options.arg_token.clone() {
Some(token) => token,
None => {
- let src = try!(SourceId::for_central(config));
+ let src = try!(SourceId::crates_io(config));
let mut src = RegistrySource::new(&src, config);
try!(src.update());
let config = try!(src.config());
mod tests {
use super::PackageId;
use core::source::SourceId;
- use sources::RegistrySource;
+ use sources::CRATES_IO;
use util::ToUrl;
#[test]
fn invalid_version_handled_nicely() {
- let loc = RegistrySource::default_url().to_url().unwrap();
+ let loc = CRATES_IO.to_url().unwrap();
let repo = SourceId::for_registry(&loc);
assert!(PackageId::new("foo", "1.0", &repo).is_err());
use core::{Source, SourceId, SourceMap, Summary, Dependency, PackageId, Package};
use core::PackageSet;
use util::{CargoResult, ChainError, Config, human, profile};
+use sources::config::SourceConfigMap;
/// Source of information about a group of packages.
///
/// operations if necessary) and is ready to be queried for packages.
pub struct PackageRegistry<'cfg> {
sources: SourceMap<'cfg>,
- config: &'cfg Config,
// A list of sources which are considered "overrides" which take precedent
// when querying for packages.
source_ids: HashMap<SourceId, (SourceId, Kind)>,
locked: HashMap<SourceId, HashMap<String, Vec<(PackageId, Vec<PackageId>)>>>,
+ source_config: SourceConfigMap<'cfg>,
}
#[derive(PartialEq, Eq, Clone, Copy)]
}
impl<'cfg> PackageRegistry<'cfg> {
- pub fn new(config: &'cfg Config) -> PackageRegistry<'cfg> {
- PackageRegistry {
+ pub fn new(config: &'cfg Config) -> CargoResult<PackageRegistry<'cfg>> {
+ let source_config = try!(SourceConfigMap::new(config));
+ Ok(PackageRegistry {
sources: SourceMap::new(),
source_ids: HashMap::new(),
overrides: Vec::new(),
- config: config,
+ source_config: source_config,
locked: HashMap::new(),
- }
+ })
}
pub fn get(self, package_ids: &[PackageId]) -> PackageSet<'cfg> {
fn load(&mut self, source_id: &SourceId, kind: Kind) -> CargoResult<()> {
(|| {
- // Save off the source
- let source = source_id.load(self.config);
+ let source = try!(self.source_config.load(source_id));
+
if kind == Kind::Override {
self.overrides.push(source_id.clone());
}
use std::hash;
use std::path::Path;
use std::sync::Arc;
-use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
+use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT};
+use std::sync::atomic::Ordering::SeqCst;
+use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use url::Url;
use core::{Package, PackageId, Registry};
-use sources::{PathSource, GitSource, RegistrySource};
+use ops;
use sources::git;
+use sources::{PathSource, GitSource, RegistrySource, CRATES_IO};
use util::{human, Config, CargoResult, ToUrl};
/// A Source finds and downloads remote packages based on names and
///
/// This is the main cargo registry by default, but it can be overridden in
/// a `.cargo/config`.
- pub fn for_central(config: &Config) -> CargoResult<SourceId> {
- Ok(SourceId::for_registry(&try!(RegistrySource::url(config))))
+ pub fn crates_io(config: &Config) -> CargoResult<SourceId> {
+ let cfg = try!(ops::registry_configuration(config));
+ let url = if let Some(ref index) = cfg.index {
+ static WARNED: AtomicBool = ATOMIC_BOOL_INIT;
+ if !WARNED.swap(true, SeqCst) {
+ try!(config.shell().warn("custom registry support via \
+ the `registry.index` configuration is \
+ being removed, this functionality \
+ will not work in the future"));
+ }
+ &index[..]
+ } else {
+ CRATES_IO
+ };
+ let url = try!(url.to_url());
+ Ok(SourceId::for_registry(&url))
}
pub fn url(&self) -> &Url {
Kind::Registry => {}
_ => return false,
}
- self.inner.url.to_string() == RegistrySource::default_url()
+ self.inner.url.to_string() == CRATES_IO
}
}
return rm_rf(&target_dir);
}
- let mut registry = PackageRegistry::new(opts.config);
+ let mut registry = try!(PackageRegistry::new(opts.config));
let resolve = try!(ops::resolve_ws(&mut registry, ws));
let packages = ops::get_resolved_packages(&resolve, registry);
no_default_features: bool)
-> CargoResult<(PackageSet<'a>, Resolve)> {
- let mut registry = PackageRegistry::new(ws.config());
+ let mut registry = try!(PackageRegistry::new(ws.config()));
if let Some(source) = source {
registry.add_preloaded(try!(ws.current()).package_id().source_id(),
None => return Ok(())
};
let current = try!(ws.current());
+
let paths = paths.val.iter().map(|&(ref s, ref p)| {
// The path listed next to the string is the config file in which the
// key was located, so we want to pop off the `.cargo/config` component
rerun_if_changed: Vec::new(),
warnings: Vec::new(),
};
- for (k, value) in try!(value.table()).0 {
+ for (k, value) in try!(value.table(&lib_name)).0 {
let key = format!("{}.{}", key, k);
match &k[..] {
"rustc-flags" => {
- let (flags, definition) = try!(value.string());
+ let (flags, definition) = try!(value.string(&k));
let whence = format!("in `{}` (in {})", key,
definition.display());
let (paths, links) = try!(
output.library_links.extend(links);
}
"rustc-link-lib" => {
- let list = try!(value.list());
+ let list = try!(value.list(&k));
output.library_links.extend(list.iter()
.map(|v| v.0.clone()));
}
"rustc-link-search" => {
- let list = try!(value.list());
+ let list = try!(value.list(&k));
output.library_paths.extend(list.iter().map(|v| {
PathBuf::from(&v.0)
}));
}
"rustc-cfg" => {
- let list = try!(value.list());
+ let list = try!(value.list(&k));
output.cfgs.extend(list.iter().map(|v| v.0.clone()));
}
_ => {
- let val = try!(value.string()).0;
+ let val = try!(value.string(&k)).0;
output.metadata.push((k.clone(), val.to_string()));
}
}
/// Executes `cargo fetch`.
pub fn fetch<'a>(ws: &Workspace<'a>) -> CargoResult<(Resolve, PackageSet<'a>)> {
- let mut registry = PackageRegistry::new(ws.config());
+ let mut registry = try!(PackageRegistry::new(ws.config()));
let resolve = try!(ops::resolve_ws(&mut registry, ws));
let packages = get_resolved_packages(&resolve, registry);
for id in resolve.iter() {
}
pub fn generate_lockfile(ws: &Workspace) -> CargoResult<()> {
- let mut registry = PackageRegistry::new(ws.config());
+ let mut registry = try!(PackageRegistry::new(ws.config()));
let resolve = try!(ops::resolve_with_previous(&mut registry, ws,
Method::Everything,
None, None));
Some(resolve) => resolve,
None => return generate_lockfile(ws),
};
- let mut registry = PackageRegistry::new(opts.config);
+ let mut registry = try!(PackageRegistry::new(opts.config));
let mut to_avoid = HashSet::new();
if opts.to_update.is_empty() {
use core::{SourceId, Source, Package, Dependency, PackageIdSpec};
use core::{PackageId, Workspace};
use ops::{self, CompileFilter};
-use sources::{GitSource, PathSource, RegistrySource};
+use sources::{GitSource, PathSource, SourceConfigMap};
use util::{CargoResult, ChainError, Config, human, internal};
use util::{Filesystem, FileLock};
force: bool) -> CargoResult<()> {
let config = opts.config;
let root = try!(resolve_root(root, config));
+ let map = try!(SourceConfigMap::new(config));
let (pkg, source) = if source_id.is_git() {
try!(select_pkg(GitSource::new(source_id, config), source_id,
krate, vers, &mut |git| git.read_packages()))
source_id, krate, vers,
&mut |path| path.read_packages()))
} else {
- try!(select_pkg(RegistrySource::new(source_id, config),
+ try!(select_pkg(try!(map.load(source_id)),
source_id, krate, vers,
&mut |_| Err(human("must specify a crate to install from \
crates.io, or use --path or --git to \
try!(archive.unpack(dst.parent().unwrap()));
let manifest_path = dst.join("Cargo.toml");
- // When packages are uploaded to the registry, all path dependencies are
- // implicitly converted to registry-based dependencies, so we rewrite those
+ // When packages are uploaded to a registry, all path dependencies are
+ // implicitly converted to registry dependencies, so we rewrite those
// dependencies here.
//
// We also make sure to point all paths at `dst` instead of the previous
// location that the package was originally read from. In locking the
// `SourceId` we're telling it that the corresponding `PathSource` will be
// considered updated and we won't actually read any packages.
- let registry = try!(SourceId::for_central(config));
+ let cratesio = try!(SourceId::crates_io(config));
let precise = Some("locked".to_string());
let new_src = try!(SourceId::for_path(&dst)).with_precise(precise);
let new_pkgid = try!(PackageId::new(pkg.name(), pkg.version(), &new_src));
let new_summary = pkg.summary().clone().map_dependencies(|d| {
if !d.source_id().is_path() { return d }
- d.clone_inner().set_source_id(registry.clone()).into_dependency()
+ d.clone_inner().set_source_id(cratesio.clone()).into_dependency()
});
let mut new_manifest = pkg.manifest().clone();
new_manifest.set_summary(new_summary.override_id(new_pkgid));
// Parse all configuration options
let RegistryConfig {
token: token_config,
- index: index_config,
+ index: _index_config,
} = try!(registry_configuration(config));
let token = token.or(token_config);
- let index = index.or(index_config).unwrap_or(RegistrySource::default_url());
- let index = try!(index.to_url());
- let sid = SourceId::for_registry(&index);
+ let sid = match index {
+ Some(index) => SourceId::for_registry(&try!(index.to_url())),
+ None => try!(SourceId::crates_io(config)),
+ };
let api_host = {
let mut src = RegistrySource::new(&sid, config);
try!(src.update().chain_error(|| {
- human(format!("failed to update registry {}", index))
+ human(format!("failed to update {}", sid))
}));
(try!(src.config())).api
};
--- /dev/null
+//! Implementation of configuration for various sources
+//!
+//! This module will parse the various `source.*` TOML configuration keys into a
+//! structure usable by Cargo itself. Currently this is primarily used to map
+//! sources to one another via the `replace-with` key in `.cargo/config`.
+
+use std::collections::HashMap;
+use std::path::{Path, PathBuf};
+
+use url::Url;
+
+use core::{Source, SourceId};
+use sources::ReplacedSource;
+use util::{CargoResult, Config, ChainError, human, ToUrl};
+use util::config::ConfigValue;
+
+pub struct SourceConfigMap<'cfg> {
+ cfgs: HashMap<String, SourceConfig>,
+ id2name: HashMap<SourceId, String>,
+ config: &'cfg Config,
+}
+
+/// Configuration for a particular source, found in TOML looking like:
+///
+/// ```toml
+/// [source.crates-io]
+/// registry = 'https://github.com/rust-lang/crates.io-index'
+/// replace-with = 'foo' # optional
+/// ```
+struct SourceConfig {
+ // id this source corresponds to, inferred from the various defined keys in
+ // the configuration
+ id: SourceId,
+
+ // Name of the source that this source should be replaced with. This field
+ // is a tuple of (name, path) where path is where this configuration key was
+ // defined (the literal `.cargo/config` file).
+ replace_with: Option<(String, PathBuf)>,
+}
+
+impl<'cfg> SourceConfigMap<'cfg> {
+ pub fn new(config: &'cfg Config) -> CargoResult<SourceConfigMap<'cfg>> {
+ let mut base = try!(SourceConfigMap::empty(config));
+ if let Some(table) = try!(config.get_table("source")) {
+ for (key, value) in table.val.iter() {
+ try!(base.add_config(key, value));
+ }
+ }
+ Ok(base)
+ }
+
+ pub fn empty(config: &'cfg Config) -> CargoResult<SourceConfigMap<'cfg>> {
+ let mut base = SourceConfigMap {
+ cfgs: HashMap::new(),
+ id2name: HashMap::new(),
+ config: config,
+ };
+ base.add("crates-io", SourceConfig {
+ id: try!(SourceId::crates_io(config)),
+ replace_with: None,
+ });
+ Ok(base)
+ }
+
+ pub fn load(&self, id: &SourceId) -> CargoResult<Box<Source + 'cfg>> {
+ debug!("loading: {}", id);
+ let mut name = match self.id2name.get(id) {
+ Some(name) => name,
+ None => return Ok(id.load(self.config)),
+ };
+ let mut path = Path::new("/");
+ let orig_name = name;
+ loop {
+ let cfg = match self.cfgs.get(name) {
+ Some(cfg) => cfg,
+ None => bail!("could not find a configured source with the \
+ name `{}` when attempting to lookup `{}` \
+ (configuration in `{}`)",
+ name, orig_name, path.display()),
+ };
+ match cfg.replace_with {
+ Some((ref s, ref p)) => {
+ name = s;
+ path = p;
+ }
+ None if *id == cfg.id => return Ok(id.load(self.config)),
+ None => {
+ let new_id = cfg.id.with_precise(id.precise()
+ .map(|s| s.to_string()));
+ let src = new_id.load(self.config);
+ return Ok(Box::new(ReplacedSource::new(id, &new_id, src)))
+ }
+ }
+ debug!("following pointer to {}", name);
+ if name == orig_name {
+ bail!("detected a cycle of `replace-with` sources, the source \
+ `{}` is eventually replaced with itself \
+ (configuration in `{}`)", name, path.display())
+ }
+ }
+ }
+
+ fn add(&mut self, name: &str, cfg: SourceConfig) {
+ self.id2name.insert(cfg.id.clone(), name.to_string());
+ self.cfgs.insert(name.to_string(), cfg);
+ }
+
+ fn add_config(&mut self, name: &str, cfg: &ConfigValue) -> CargoResult<()> {
+ let (table, _path) = try!(cfg.table(&format!("source.{}", name)));
+ let mut srcs = Vec::new();
+ if let Some(val) = table.get("registry") {
+ let url = try!(url(val, &format!("source.{}.registry", name)));
+ srcs.push(SourceId::for_registry(&url));
+ }
+
+ let mut srcs = srcs.into_iter();
+ let src = try!(srcs.next().chain_error(|| {
+ human(format!("no source URL specified for `source.{}`, needs \
+ `registry` defined", name))
+ }));
+ if srcs.next().is_some() {
+ return Err(human(format!("more than one source URL specified for \
+ `source.{}`", name)))
+ }
+
+ let mut replace_with = None;
+ if let Some(val) = table.get("replace-with") {
+ let (s, path) = try!(val.string(&format!("source.{}.replace-with",
+ name)));
+ replace_with = Some((s.to_string(), path.to_path_buf()));
+ }
+
+ self.add(name, SourceConfig {
+ id: src,
+ replace_with: replace_with,
+ });
+
+ return Ok(());
+
+ fn url(cfg: &ConfigValue, key: &str) -> CargoResult<Url> {
+ let (url, path) = try!(cfg.string(key));
+ url.to_url().chain_error(|| {
+ human(format!("configuration key `{}` specified an invalid \
+ URL (in {})", key, path.display()))
+
+ })
+ }
+ }
+}
pub use self::path::PathSource;
pub use self::git::GitSource;
-pub use self::registry::RegistrySource;
+pub use self::registry::{RegistrySource, CRATES_IO};
+pub use self::replaced::ReplacedSource;
+pub use self::config::SourceConfigMap;
pub mod path;
pub mod git;
pub mod registry;
+pub mod config;
+pub mod replaced;
use util::network;
use ops;
-const DEFAULT: &'static str = "https://github.com/rust-lang/crates.io-index";
const INDEX_LOCK: &'static str = ".cargo-index-lock";
+pub static CRATES_IO: &'static str = "https://github.com/rust-lang/crates.io-index";
pub struct RegistrySource<'cfg> {
source_id: SourceId,
}
}
- /// Get the configured default registry URL.
- ///
- /// This is the main cargo registry by default, but it can be overridden in
- /// a .cargo/config
- pub fn url(config: &Config) -> CargoResult<Url> {
- let config = try!(ops::registry_configuration(config));
- let url = config.index.unwrap_or(DEFAULT.to_string());
- url.to_url()
- }
-
- /// Get the default url for the registry
- pub fn default_url() -> String {
- DEFAULT.to_string()
- }
-
/// Decode the configuration stored within the registry.
///
/// This requires that the index has been at least checked out.
--- /dev/null
+use core::{Source, Registry, PackageId, Package, Dependency, Summary, SourceId};
+use util::{CargoResult, ChainError, human};
+
+pub struct ReplacedSource<'cfg> {
+ to_replace: SourceId,
+ replace_with: SourceId,
+ inner: Box<Source + 'cfg>,
+}
+
+impl<'cfg> ReplacedSource<'cfg> {
+ pub fn new(to_replace: &SourceId,
+ replace_with: &SourceId,
+ src: Box<Source + 'cfg>) -> ReplacedSource<'cfg> {
+ ReplacedSource {
+ to_replace: to_replace.clone(),
+ replace_with: replace_with.clone(),
+ inner: src,
+ }
+ }
+}
+
+impl<'cfg> Registry for ReplacedSource<'cfg> {
+ fn query(&mut self, dep: &Dependency) -> CargoResult<Vec<Summary>> {
+ let dep = dep.clone().map_source(&self.to_replace, &self.replace_with);
+ let ret = try!(self.inner.query(&dep).chain_error(|| {
+ human(format!("failed to query replaced source `{}`",
+ self.to_replace))
+ }));
+ Ok(ret.into_iter().map(|summary| {
+ summary.map_source(&self.replace_with, &self.to_replace)
+ }).collect())
+ }
+}
+
+impl<'cfg> Source for ReplacedSource<'cfg> {
+ fn update(&mut self) -> CargoResult<()> {
+ self.inner.update().chain_error(|| {
+ human(format!("failed to update replaced source `{}`",
+ self.to_replace))
+ })
+ }
+
+ fn download(&mut self, id: &PackageId) -> CargoResult<Package> {
+ let id = id.with_source_id(&self.replace_with);
+ let pkg = try!(self.inner.download(&id).chain_error(|| {
+ human(format!("failed to download replaced source `{}`",
+ self.to_replace))
+ }));
+ Ok(pkg.map_source(&self.replace_with, &self.to_replace))
+ }
+
+ fn fingerprint(&self, id: &Package) -> CargoResult<String> {
+ self.inner.fingerprint(id)
+ }
+}
}
pub fn expected<T>(&self, ty: &str, key: &str, val: CV) -> CargoResult<T> {
- val.expected(ty).map_err(|e| {
+ val.expected(ty, key).map_err(|e| {
human(format!("invalid configuration for key `{}`\n{}", key, e))
})
}
Ok(())
}
- pub fn i64(&self) -> CargoResult<(i64, &Path)> {
+ pub fn i64(&self, key: &str) -> CargoResult<(i64, &Path)> {
match *self {
CV::Integer(i, ref p) => Ok((i, p)),
- _ => self.expected("integer"),
+ _ => self.expected("integer", key),
}
}
- pub fn string(&self) -> CargoResult<(&str, &Path)> {
+ pub fn string(&self, key: &str) -> CargoResult<(&str, &Path)> {
match *self {
CV::String(ref s, ref p) => Ok((s, p)),
- _ => self.expected("string"),
+ _ => self.expected("string", key),
}
}
- pub fn table(&self) -> CargoResult<(&HashMap<String, ConfigValue>, &Path)> {
+ pub fn table(&self, key: &str)
+ -> CargoResult<(&HashMap<String, ConfigValue>, &Path)> {
match *self {
CV::Table(ref table, ref p) => Ok((table, p)),
- _ => self.expected("table"),
+ _ => self.expected("table", key),
}
}
- pub fn list(&self) -> CargoResult<&[(String, PathBuf)]> {
+ pub fn list(&self, key: &str) -> CargoResult<&[(String, PathBuf)]> {
match *self {
CV::List(ref list, _) => Ok(list),
- _ => self.expected("list"),
+ _ => self.expected("list", key),
}
}
- pub fn boolean(&self) -> CargoResult<(bool, &Path)> {
+ pub fn boolean(&self, key: &str) -> CargoResult<(bool, &Path)> {
match *self {
CV::Boolean(b, ref p) => Ok((b, p)),
- _ => self.expected("bool"),
+ _ => self.expected("bool", key),
}
}
}
}
- fn expected<T>(&self, wanted: &str) -> CargoResult<T> {
- Err(internal(format!("expected a {}, but found a {} in {}",
- wanted, self.desc(),
- self.definition_path().display())))
+ fn expected<T>(&self, wanted: &str, key: &str) -> CargoResult<T> {
+ Err(human(format!("expected a {}, but found a {} for `{}` in {}",
+ wanted, self.desc(), key,
+ self.definition_path().display())))
}
fn into_toml(self) -> toml::Value {
cx.source_id.clone()
}
},
- (None, None) => try!(SourceId::for_central(cx.config)),
+ (None, None) => try!(SourceId::crates_io(cx.config)),
};
let version = details.version.as_ref().map(|v| &v[..]);
proxy = true
"#);
Package::new("foo", "1.0.0").publish();
+
assert_that(foo.cargo_process("publish").arg("-v"),
execs().with_status(101).with_stderr("\
[UPDATING] registry `[..]`
[ERROR] invalid configuration for key `http.proxy`
-expected a string, but found a boolean in [..]config
+expected a string, but found a boolean for `http.proxy` in [..]config
"));
}
Caused by:
invalid configuration for key `cargo-new.name`
-expected a string, but found a boolean in [..]config
+expected a string, but found a boolean for `cargo-new.name` in [..]config
"));
}
"));
}
+#[test]
+fn bad_source_config1() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+ "#)
+ .file("src/lib.rs", "")
+ .file(".cargo/config", r#"
+ [source.foo]
+ "#);
+
+ assert_that(p.cargo_process("build"),
+ execs().with_status(101).with_stderr("\
+error: no source URL specified for `source.foo`, needs [..]
+"));
+}
+
+#[test]
+fn bad_source_config2() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+
+ [dependencies]
+ bar = "*"
+ "#)
+ .file("src/lib.rs", "")
+ .file(".cargo/config", r#"
+ [source.crates-io]
+ registry = 'http://example.com'
+ replace-with = 'bar'
+ "#);
+
+ assert_that(p.cargo_process("build"),
+ execs().with_status(101).with_stderr("\
+error: failed to load source for a dependency on `bar`
+
+Caused by:
+ Unable to update registry https://[..]
+
+Caused by:
+ could not find a configured source with the name `bar` \
+ when attempting to lookup `crates-io` (configuration in [..])
+"));
+}
+
+#[test]
+fn bad_source_config3() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+
+ [dependencies]
+ bar = "*"
+ "#)
+ .file("src/lib.rs", "")
+ .file(".cargo/config", r#"
+ [source.crates-io]
+ registry = 'http://example.com'
+ replace-with = 'crates-io'
+ "#);
+
+ assert_that(p.cargo_process("build"),
+ execs().with_status(101).with_stderr("\
+error: failed to load source for a dependency on `bar`
+
+Caused by:
+ Unable to update registry https://[..]
+
+Caused by:
+ detected a cycle of `replace-with` sources, [..]
+"));
+}
+
+#[test]
+fn bad_source_config4() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+
+ [dependencies]
+ bar = "*"
+ "#)
+ .file("src/lib.rs", "")
+ .file(".cargo/config", r#"
+ [source.crates-io]
+ registry = 'http://example.com'
+ replace-with = 'bar'
+
+ [source.bar]
+ registry = 'http://example.com'
+ replace-with = 'crates-io'
+ "#);
+
+ assert_that(p.cargo_process("build"),
+ execs().with_status(101).with_stderr("\
+error: failed to load source for a dependency on `bar`
+
+Caused by:
+ Unable to update registry https://[..]
+
+Caused by:
+ detected a cycle of `replace-with` sources, the source `crates-io` is \
+ eventually replaced with itself (configuration in [..])
+"));
+}
+
+#[test]
+fn bad_source_config5() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+
+ [dependencies]
+ bar = "*"
+ "#)
+ .file("src/lib.rs", "")
+ .file(".cargo/config", r#"
+ [source.crates-io]
+ registry = 'http://example.com'
+ replace-with = 'bar'
+
+ [source.bar]
+ registry = 'not a url'
+ "#);
+
+ assert_that(p.cargo_process("build"),
+ execs().with_status(101).with_stderr("\
+error: configuration key `source.bar.registry` specified an invalid URL (in [..])
+
+Caused by:
+ invalid url `not a url`: [..]
+"));
+}
+
#[test]
fn both_git_and_path_specified() {
let foo = project("foo")
"));
}
+#[test]
+fn bad_source_config6() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+
+ [dependencies]
+ bar = "*"
+ "#)
+ .file("src/lib.rs", "")
+ .file(".cargo/config", r#"
+ [source.crates-io]
+ registry = 'http://example.com'
+ replace-with = ['not', 'a', 'string']
+ "#);
+
+ assert_that(p.cargo_process("build"),
+ execs().with_status(101).with_stderr("\
+error: expected a string, but found a array for `source.crates-io.replace-with` in [..]
+"));
+}
+
#[test]
fn ignored_git_revision() {
let foo = project("foo")
[WARNING] key `branch` is ignored for dependency (bar). \
This will be considered an error in future versions"));
}
+
+#[test]
+#[ignore]
+fn bad_source_config7() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+
+ [dependencies]
+ bar = "*"
+ "#)
+ .file("src/lib.rs", "")
+ .file(".cargo/config", r#"
+ [source.foo]
+ registry = 'http://example.com'
+ directory = 'file:///another/file'
+ "#);
+
+ Package::new("bar", "0.1.0").publish();
+
+ assert_that(p.cargo_process("build"),
+ execs().with_status(101).with_stderr("\
+error: more than one source URL specified for `source.foo`
+"));
+}
+
+#[test]
+#[ignore]
+fn bad_source_config8() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+
+ [dependencies]
+ bar = "*"
+ "#)
+ .file("src/lib.rs", "")
+ .file(".cargo/config", r#"
+ [source.foo]
+ directory = 'file://another/file'
+ "#);
+
+ assert_that(p.cargo_process("build"),
+ execs().with_status(101).with_stderr("\
+error: failed to convert `file://another/file` to an absolute path (configured in [..])
+"));
+}
.with_stderr("\
[UPDATING] registry `[..]`
[DOWNLOADING] bar v0.1.0 ([..])
-[COMPILING] bar v0.1.0 ([..])
+[COMPILING] bar v0.1.0
[RUNNING] `rustc [..]`
[RUNNING] `[..]`
[RUNNING] `rustc [..]`
.with_stderr("\
[UPDATING] registry `[..]`
[DOWNLOADING] bar v0.1.0 ([..])
-[COMPILING] bar v0.1.0 ([..])
+[COMPILING] bar v0.1.0
[RUNNING] `rustc [..]`
[RUNNING] `[..]`
warning: foo
execs().with_status(101).
with_stderr_contains("[ERROR] invalid configuration \
for key `alias.b-cargo-test`
-expected a list, but found a integer in [..]"));
+expected a list, but found a integer for [..]"));
}
}
t!(t!(File::create(&config)).write_all(format!(r#"
[registry]
- index = "{reg}"
token = "api-token"
+
+ [source.crates-io]
+ registry = 'https://wut'
+ replace-with = 'dummy-registry'
+
+ [source.dummy-registry]
+ registry = '{reg}'
"#, reg = registry()).as_bytes()));
// Init a new registry
repo(®istry_path())
.file("config.json", &format!(r#"
- {{"dl":"{}","api":""}}
+ {{"dl":"{0}","api":"{0}"}}
"#, dl_url()))
.build();
+ fs::create_dir_all(dl_path().join("api/v1/crates")).unwrap();
}
impl Package {
assert_that(cargo_process("install").arg("foo"),
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `[..]`
-[DOWNLOADING] foo v0.0.1 (registry file://[..])
-[COMPILING] foo v0.0.1 (registry file://[..])
+[DOWNLOADING] foo v0.0.1 (registry [..])
+[COMPILING] foo v0.0.1
[FINISHED] release [optimized] target(s) in [..]
[INSTALLING] {home}[..]bin[..]foo[..]
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
[UPDATING] registry `[..]`
[DOWNLOADING] foo v0.0.2 (registry file://[..])
[COMPILING] foo v0.0.2 (registry file://[..])
+[DOWNLOADING] foo v0.0.2 (registry [..])
+[COMPILING] foo v0.0.2
[FINISHED] release [optimized] target(s) in [..]
[INSTALLING] {home}[..]bin[..]foo[..]
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
assert_that(cargo_process("install").arg("bar"),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
-[ERROR] could not find `bar` in `registry file://[..]`
+[ERROR] could not find `bar` in `registry [..]`
"));
}
assert_that(cargo_process("install").arg("foo").arg("--vers=0.2.0"),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
-[ERROR] could not find `foo` in `registry file://[..]` with version `0.2.0`
+[ERROR] could not find `foo` in `registry [..]` with version `0.2.0`
"));
}
assert_that(cargo_process("install").arg("--path").arg(p.root()),
execs().with_status(101).with_stderr_contains("\
-[ERROR] failed to compile `foo v0.1.0 (file://[..])`, intermediate artifacts can be \
+[ERROR] failed to compile `foo v0.1.0 ([..])`, intermediate artifacts can be \
found at `[..]target`
Caused by:
execs().with_status(0));
assert_that(cargo_process("install").arg("--list"),
execs().with_status(0).with_stdout("\
-bar v0.2.1 (registry [..]):
+bar v0.2.1:
bar[..]
-foo v0.0.1 (registry [..]):
+foo v0.0.1:
foo[..]
"));
}
execs().with_status(0));
assert_that(cargo_process("uninstall").arg("foo").arg("--bin=bar"),
execs().with_status(101).with_stderr("\
-[ERROR] binary `bar[..]` not installed as part of `foo v0.0.1 ([..])`
+[ERROR] binary `bar[..]` not installed as part of `foo v0.0.1`
"));
}
{
"dependencies": [],
"features": {},
- "id": "baz 0.0.1 (registry+file:[..])",
+ "id": "baz 0.0.1 (registry+[..])",
"manifest_path": "[..]Cargo.toml",
"name": "baz",
- "source": "registry+file:[..]",
+ "source": "registry+[..]",
"targets": [
{
"kind": [
"name": "baz",
"optional": false,
"req": "^0.0.1",
- "source": "registry+file:[..]",
+ "source": "registry+[..]",
"target": null,
"uses_default_features": true
}
],
"features": {},
- "id": "bar 0.0.1 (registry+file:[..])",
+ "id": "bar 0.0.1 (registry+[..])",
"manifest_path": "[..]Cargo.toml",
"name": "bar",
- "source": "registry+file:[..]",
+ "source": "registry+[..]",
"targets": [
{
"kind": [
"name": "bar",
"optional": false,
"req": "*",
- "source": "registry+file:[..]",
+ "source": "registry+[..]",
"target": null,
"uses_default_features": true
}
"nodes": [
{
"dependencies": [
- "bar 0.0.1 (registry+file:[..])"
+ "bar 0.0.1 (registry+[..])"
],
"id": "foo 0.5.0 (path+file:[..]foo)"
},
{
"dependencies": [
- "baz 0.0.1 (registry+file:[..])"
+ "baz 0.0.1 (registry+[..])"
],
- "id": "bar 0.0.1 (registry+file:[..])"
+ "id": "bar 0.0.1 (registry+[..])"
},
{
"dependencies": [],
- "id": "baz 0.0.1 (registry+file:[..])"
+ "id": "baz 0.0.1 (registry+[..])"
}
],
"root": "foo 0.5.0 (path+file:[..]foo)"
use cargotest::support::git;
use cargotest::support::paths;
-use cargotest::support::registry::{registry, Package};
+use cargotest::support::registry::Package;
use cargotest::support::{execs, project};
use hamcrest::assert_that;
[UPDATING] git repository `[..]`
[DOWNLOADING] bar v0.2.0 (registry [..])
[COMPILING] foo v0.1.0 (file://[..])
-[COMPILING] bar v0.2.0 (registry [..])
+[COMPILING] bar v0.2.0
[COMPILING] local v0.0.1 (file://[..])
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
"));
[UPDATING] registry `file://[..]`
[UPDATING] git repository `[..]`
[DOWNLOADING] foo v0.1.1 (registry [..])
-[COMPILING] foo v0.1.1 (registry [..])
+[COMPILING] foo v0.1.1
[COMPILING] bar v0.1.0 ([..])
[COMPILING] local v0.0.1 (file://[..])
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
execs().with_status(0).with_stderr("\
[UPDATING] git repository `file://[..]`
"));
- assert_that(p.cargo("update").arg("-p").arg(&format!("{}#bar", registry())),
+ assert_that(p.cargo("update")
+ .arg("-p")
+ .arg("https://github.com/rust-lang/crates.io-index#bar"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
"));
[replace]
"foo:0.1.0" = {{ git = '{0}' }}
- "{1}#foo:0.1.0" = {{ git = '{0}' }}
- "#, foo.url(), registry()))
+
+ [replace."https://github.com/rust-lang/crates.io-index#foo:0.1.0"]
+ git = '{0}'
+ "#, foo.url()))
.file("src/lib.rs", "");
assert_that(p.cargo_process("build"),
* [..]
* [..]
-both specifications match: foo v0.1.0 ([..])
+both specifications match: foo v0.1.0
"));
}
fn setup() {
let config = paths::root().join(".cargo/config");
- fs::create_dir_all(config.parent().unwrap()).unwrap();
- File::create(&config).unwrap().write_all(&format!(r#"
+ t!(fs::create_dir_all(config.parent().unwrap()));
+ t!(t!(File::create(&config)).write_all(&format!(r#"
[registry]
- index = "{reg}"
token = "api-token"
- "#, reg = registry()).as_bytes()).unwrap();
- fs::create_dir_all(&upload_path().join("api/v1/crates")).unwrap();
+ "#).as_bytes()));
+ t!(fs::create_dir_all(&upload_path().join("api/v1/crates")));
repo(®istry_path())
.file("config.json", &format!(r#"{{
"#)
.file("src/main.rs", "fn main() {}");
- assert_that(p.cargo_process("publish").arg("--no-verify"),
+ assert_that(p.cargo_process("publish").arg("--no-verify")
+ .arg("--host").arg(registry().to_string()),
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `{reg}`
[WARNING] manifest has no documentation, [..]
"#)
.file("src/main.rs", "fn main() {}");
- assert_that(p.cargo_process("publish").arg("-v").arg("--no-verify"),
+ assert_that(p.cargo_process("publish").arg("-v").arg("--no-verify")
+ .arg("--host").arg(registry().to_string()),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
[ERROR] all dependencies must come from the same source.
"#)
.file("bar/src/lib.rs", "");
- assert_that(p.cargo_process("publish"),
+ assert_that(p.cargo_process("publish")
+ .arg("--host").arg(registry().to_string()),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
[ERROR] all path dependencies must have a version specified when publishing.
"#)
.file("src/main.rs", "fn main() {}");
- assert_that(p.cargo_process("publish"),
+ assert_that(p.cargo_process("publish")
+ .arg("--host").arg(registry().to_string()),
execs().with_status(101).with_stderr("\
[ERROR] some crates cannot be published.
`foo` is marked as unpublishable
let p = project("foo");
t!(File::create(p.root().join("bar")));
- assert_that(p.cargo("publish"),
+ assert_that(p.cargo("publish")
+ .arg("--host").arg(registry().to_string()),
execs().with_status(101).with_stderr("\
[UPDATING] registry `[..]`
error: 1 dirty files found in the working directory:
.build();
let p = project("foo");
- assert_that(p.cargo("publish"),
+ assert_that(p.cargo("publish")
+ .arg("--host").arg(registry().to_string()),
execs().with_status(0));
}
let p = project("foo");
t!(File::create(p.root().join("baz")));
- assert_that(p.cargo("publish").cwd(p.root().join("bar")),
+ assert_that(p.cargo("publish").cwd(p.root().join("bar"))
+ .arg("--host").arg(registry().to_string()),
execs().with_status(0));
}
let p = project("foo");
t!(File::create(p.root().join("baz")));
- assert_that(p.cargo("publish"),
+ assert_that(p.cargo("publish")
+ .arg("--host").arg(registry().to_string()),
execs().with_status(0));
}
.nocommit_file("bar/src/main.rs", "fn main() {}");
let p = project("foo");
t!(File::create(p.root().join("bar/baz")));
- assert_that(p.cargo("publish").cwd(p.root().join("bar")),
+ assert_that(p.cargo("publish").cwd(p.root().join("bar"))
+ .arg("--host").arg(registry().to_string()),
execs().with_status(0));
}
.nocommit_file("src/main.rs", "fn main() {}");
let p = project("foo");
t!(File::create(p.root().join("baz")));
- assert_that(p.cargo("publish"),
+ assert_that(p.cargo("publish")
+ .arg("--host").arg(registry().to_string()),
execs().with_status(101));
}
"#)
.file("src/main.rs", "fn main() {}");
- assert_that(p.cargo_process("publish").arg("--dry-run"),
+ assert_that(p.cargo_process("publish").arg("--dry-run")
+ .arg("--host").arg(registry().to_string()),
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `{reg}`
[WARNING] manifest has no documentation, [..]
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `{reg}`
[DOWNLOADING] bar v0.0.1 (registry file://[..])
-[COMPILING] bar v0.0.1 (registry file://[..])
+[COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
",
assert_that(p.cargo_process("build"),
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `{reg}`
-[..] bar v0.0.1 (registry file://[..])
-[..] foo v0.0.1 ({dir})
+[COMPILING] bar v0.0.1
+[COMPILING] foo v0.0.1 ({dir})
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
",
dir = p.url(),
[UPDATING] registry `{reg}`
[DOWNLOADING] [..] v0.0.1 (registry file://[..])
[DOWNLOADING] [..] v0.0.1 (registry file://[..])
-[COMPILING] baz v0.0.1 (registry file://[..])
-[COMPILING] bar v0.0.1 (registry file://[..])
+[COMPILING] baz v0.0.1
+[COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
",
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
[ERROR] no matching package named `nonexistent` found (required by `foo`)
-location searched: registry file://[..]
+location searched: registry [..]
version required: >= 0.0.0
"));
}
assert_that(p.cargo_process("build"),
execs().with_status(101).with_stderr_contains("\
[ERROR] no matching package named `foo` found (required by `foo`)
-location searched: registry file://[..]
+location searched: registry [..]
version required: >= 1.0.0
versions found: 0.0.2, 0.0.1
"));
assert_that(p.cargo_process("build"),
execs().with_status(101).with_stderr_contains("\
[ERROR] no matching package named `foo` found (required by `foo`)
-location searched: registry file://[..]
+location searched: registry [..]
version required: >= 1.0.0
versions found: 0.0.4, 0.0.3, 0.0.2, ...
"));
[DOWNLOADING] bad-cksum [..]
[ERROR] unable to get packages from source
+Caused by:
+ failed to download replaced source `registry https://[..]`
+
Caused by:
failed to download package `bad-cksum v0.0.1 (registry file://[..])` from [..]
assert_that(p.cargo_process("build"),
execs().with_status(101).with_stderr_contains("\
[ERROR] no matching package named `notyet` found (required by `foo`)
-location searched: registry file://[..]
+location searched: registry [..]
version required: >= 0.0.0
"));
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `{reg}`
[DOWNLOADING] notyet v0.0.1 (registry file://[..])
-[COMPILING] notyet v0.0.1 (registry file://[..])
+[COMPILING] notyet v0.0.1
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
",
Caused by:
no matching package named `notyet` found (required by `foo`)
-location searched: registry file://[..]
+location searched: registry [..]
version required: ^0.0.1
"));
[VERIFYING] foo v0.0.1 ({dir})
[UPDATING] registry `[..]`
[DOWNLOADING] notyet v0.0.1 (registry file://[..])
-[COMPILING] notyet v0.0.1 (registry file://[..])
+[COMPILING] notyet v0.0.1
[COMPILING] foo v0.0.1 ({dir}[..])
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
", dir = p.url())));
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `[..]`
[DOWNLOADING] bar v0.0.1 (registry file://[..])
-[COMPILING] bar v0.0.1 (registry file://[..])
+[COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
",
[UPDATING] registry `[..]`
[DOWNLOADING] [..] v0.0.1 (registry file://[..])
[DOWNLOADING] [..] v0.0.1 (registry file://[..])
-[COMPILING] baz v0.0.1 (registry file://[..])
-[COMPILING] bar v0.0.1 (registry file://[..])
+[COMPILING] baz v0.0.1
+[COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
",
[UPDATING] registry `[..]`
[DOWNLOADING] [..] v0.0.1 (registry file://[..])
[DOWNLOADING] [..] v0.0.1 (registry file://[..])
-[COMPILING] baz v0.0.1 (registry file://[..])
-[COMPILING] bar v0.0.1 (registry file://[..])
+[COMPILING] baz v0.0.1
+[COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
",
assert_that(p.cargo("build"),
execs().with_status(101).with_stderr_contains("\
[ERROR] no matching package named `baz` found (required by `bar`)
-location searched: registry file://[..]
+location searched: registry [..]
version required: = 0.0.2
versions found: 0.0.1
"));
assert_that(p.cargo("update"),
execs().with_status(101).with_stderr_contains("\
[ERROR] no matching package named `bar` found (required by `foo`)
-location searched: registry file://[..]
+location searched: registry [..]
version required: *
"));
}
.arg("-p").arg("bar").arg("--precise").arg("0.0.2"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `[..]`
-[UPDATING] bar v0.0.1 (registry file://[..]) -> v0.0.2
+[UPDATING] bar v0.0.1 -> v0.0.2
"));
println!("0.0.2 build");
assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(&format!("\
[DOWNLOADING] [..] v0.0.2 (registry file://[..])
-[COMPILING] bar v0.0.2 (registry file://[..])
+[COMPILING] bar v0.0.2
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
",
.arg("-p").arg("bar"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `[..]`
-[UPDATING] bar v0.0.2 (registry file://[..]) -> v0.0.3
+[UPDATING] bar v0.0.2 -> v0.0.3
"));
println!("0.0.3 build");
assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(&format!("\
[DOWNLOADING] [..] v0.0.3 (registry file://[..])
-[COMPILING] bar v0.0.3 (registry file://[..])
+[COMPILING] bar v0.0.3
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
",
.arg("-p").arg("bar"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `[..]`
-[UPDATING] bar v0.0.3 (registry file://[..]) -> v0.0.4
-[ADDING] spam v0.2.5 (registry file://[..])
+[UPDATING] bar v0.0.3 -> v0.0.4
+[ADDING] spam v0.2.5
"));
println!("new dependencies update");
.arg("-p").arg("bar"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `[..]`
-[UPDATING] bar v0.0.4 (registry file://[..]) -> v0.0.5
-[REMOVING] spam v0.2.5 (registry file://[..])
+[UPDATING] bar v0.0.4 -> v0.0.5
+[REMOVING] spam v0.2.5
"));
}
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `[..]`
[DOWNLOADING] [..] v0.0.1 (registry file://[..])
-[COMPILING] bar v0.0.1 (registry file://[..])
+[COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
",
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `[..]`
[DOWNLOADING] bar v0.0.1 (registry file://[..])
-[COMPILING] bar v0.0.1 (registry file://[..])
+[COMPILING] bar v0.0.1
[COMPILING] a v0.0.1 ({dir}/a)
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `[..]`
[DOWNLOADING] bar v0.1.0 (registry file://[..])
-[COMPILING] bar v0.1.0 (registry file://[..])
+[COMPILING] bar v0.1.0
[COMPILING] a v0.0.1 ({dir}/a)
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
[UPDATING] [..]
[UPDATING] [..]
[DOWNLOADING] a v0.0.1 (registry file://[..])
-[COMPILING] a v0.0.1 (registry [..])
+[COMPILING] a v0.0.1
[COMPILING] b v0.0.1 ([..])
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
"#)
.file("src/main.rs", "fn main() {}");
p.build();
-
Package::new("a", "0.1.0").publish();
-
assert_that(p.cargo("build"),
execs().with_status(0));
execs().with_status(0).with_stderr(&format!("\
[UPDATING] [..]
[DOWNLOADING] a v0.1.1 (registry file://[..])
-[COMPILING] a v0.1.1 (registry [..])
+[COMPILING] a v0.1.1
[COMPILING] foo v0.5.0 ({dir})
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
",
execs().with_status(0)
.with_stderr("\
[UPDATING] registry `[..]`
-[UPDATING] b v0.1.0 (registry [..]) -> v0.1.1
+[UPDATING] b v0.1.0 -> v0.1.1
"));
assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr("\
[DOWNLOADING] b v0.1.1 (registry file://[..])
-[COMPILING] b v0.1.1 (registry [..])
-[COMPILING] a v0.1.0 (registry [..])
+[COMPILING] b v0.1.1
+[COMPILING] a v0.1.0
[COMPILING] foo v0.5.0 ([..])
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
"));
execs().with_status(0)
.with_stderr("\
[UPDATING] registry `[..]`
-[UPDATING] a v0.1.0 (registry [..]) -> v0.1.1
-[UPDATING] b v0.1.0 (registry [..]) -> v0.1.1
+[UPDATING] a v0.1.0 -> v0.1.1
+[UPDATING] b v0.1.0 -> v0.1.1
"));
assert_that(p.cargo("update").arg("-pb").arg("-pc"),
execs().with_status(0)
.with_stderr("\
[UPDATING] registry `[..]`
-[UPDATING] c v0.1.0 (registry [..]) -> v0.1.1
+[UPDATING] c v0.1.0 -> v0.1.1
"));
assert_that(p.cargo("build"),
.with_stderr_contains("\
[DOWNLOADING] c v0.1.1 (registry file://[..])")
.with_stderr_contains("\
-[COMPILING] a v0.1.1 (registry [..])")
+[COMPILING] a v0.1.1")
.with_stderr_contains("\
-[COMPILING] b v0.1.1 (registry [..])")
+[COMPILING] b v0.1.1")
.with_stderr_contains("\
-[COMPILING] c v0.1.1 (registry [..])")
+[COMPILING] c v0.1.1")
.with_stderr_contains("\
[COMPILING] foo v0.5.0 ([..])"));
}
execs().with_status(0).with_stderr("\
[UPDATING] registry `[..]`
[DOWNLOADING] baz v0.1.0 ([..])
-[COMPILING] baz v0.1.0 ([..])
+[COMPILING] baz v0.1.0
[COMPILING] bar v0.5.0 ([..])
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] secs
"));
fn setup() {
let config = paths::root().join(".cargo/config");
fs::create_dir_all(config.parent().unwrap()).unwrap();
- File::create(&config).unwrap().write_all(format!(r#"
- [registry]
- index = "{reg}"
- "#, reg = registry()).as_bytes()).unwrap();
fs::create_dir_all(&api_path().join("api/v1")).unwrap();
repo(®istry_path())
.write_all(contents.as_bytes()).unwrap();
}
- assert_that(cargo_process("search").arg("postgres"),
+ assert_that(cargo_process("search").arg("postgres")
+ .arg("--host").arg(registry().to_string()),
execs().with_status(0)
.with_stderr("\
[UPDATING] registry `[..]`")
.write_all(contents.as_bytes()).unwrap();
}
- assert_that(cargo_process("search").arg("postgres").arg("sql"),
+ assert_that(cargo_process("search").arg("postgres").arg("sql")
+ .arg("--host").arg(registry().to_string()),
execs().with_status(0)
.with_stderr("\
[UPDATING] registry `[..]`")
.with_stderr("\
[UPDATING] registry `[..]`
[DOWNLOADING] dep1 v0.1.3 ([..])
-[COMPILING] dep1 v0.1.3 ([..])
+[COMPILING] dep1 v0.1.3
[COMPILING] foo v0.1.0 ([..])
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
"));
execs().with_status(0)
.with_stderr("\
[DOWNLOADING] dep2 v0.1.0 ([..])
-[COMPILING] dep2 v0.1.0 ([..])
+[COMPILING] dep2 v0.1.0
[COMPILING] foo v0.1.0 ([..])
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
"));
execs().with_status(0)
.with_stderr("\
[DOWNLOADING] dep1 v0.1.0 ([..])
-[COMPILING] dep1 v0.1.0 ([..])
+[COMPILING] dep1 v0.1.0
[COMPILING] bar v0.1.0 ([..])
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
"));